package com.atguigu.day07;

import org.apache.flink.api.common.functions.MapFunction;
import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

public class Flink04_Union {
    public static void main(String[] args) throws Exception {
        //1.获取流的执行环境
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        env.setParallelism(1);

        //2.创建两条流
        DataStreamSource<String> numStr = env.fromElements("1", "2", "3", "4");
        DataStreamSource<String> abcStr = env.fromElements("a", "b", "c", "d","e");

        //TODO 3.使用Union链接两条流
        DataStream<String> newStream = numStr.union(abcStr);

        newStream.map(new MapFunction<String, String>() {
            @Override
            public String map(String value) throws Exception {
                return value + "aaaaaaaaaaaaa";
            }
        }).print();


        env.execute();
    }
}
